package in.co.codedoc.sql.mapping;

import java.sql.ResultSet;
import java.sql.SQLException;

import in.co.codedoc.sql.DBOutputColumnMap;
import in.co.codedoc.sql.SQLStatement;

public class CharStringOutputColumnMap extends DBOutputColumnMap
	implements StringOutputColumnMap
{
	public static DBOutputColumnMap GetDBOutputColumnMap()
	{
		return new CharStringOutputColumnMap();
	}
	@Override
	public void ReadColumn(int index, ResultSet rs)
		throws SQLException
	{
		v = rs.getString(index);
		
		if(Logger.logger.isDebugEnabled())
		{
			if(index > 1)
			{
				SQLStatement.GetDebugStringBuffer().append(",");
			}
		}
		
		if(rs.wasNull())
		{
			if(Logger.logger.isDebugEnabled())
			{
				SQLStatement.GetDebugStringBuffer().append("<NULL>");
			}
			
			SetWasNull();
		}
		else
		{
			if(Logger.logger.isDebugEnabled())
			{
				SQLStatement.GetDebugStringBuffer().append('"').append(v).append('"');
			}			
		}
	}
	
	public String GetValue()
	{
		return v;
	}
	
	private String v;
}
